package org.ckq.json;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;

public class JsonTest {

    public static void main(String[] args) {
        String s = "{\"a,a\":{\"next\":\"aa,ab\"},\"bb\":\"cc:cc\\\"\",\"c3\": [12,null,false]}";
        URL url = JsonTest.class.getResource("test.json");
        URI uri = null;
        try {
            uri = url.toURI();
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
        File file = new File(uri);
        s = readToString(file);
        Object o = JSON.parse(s);
        System.out.println(o);
    }

    public static String readToString(File file) {
        Long filelength = file.length();
        byte[] filecontent = new byte[filelength.intValue()];
        try {
            FileInputStream in = new FileInputStream(file);
            in.read(filecontent);
            in.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return new String(filecontent);
    }
}
